
Date.prototype.format = function (format) {
	/*时间格式化
	 * eg:format="yyyy-MM-dd hh:mm:ss";
	 */
	if (!format) {
		format = "yyyy-MM-dd hh:mm:ss";
	}
	
	var o = {
		"M+" : this.getMonth() + 1, // month
		"d+" : this.getDate(), // day
		"h+" : this.getHours(), // hour
		"m+" : this.getMinutes(), // minute
		"s+" : this.getSeconds(), // second
		"q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
		"S" : this.getMilliseconds()
		// millisecond
	};
	
	if (/(y+)/.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	}
	
	for (var k in o) {
		if (new RegExp("(" + k + ")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
		}
	}
	return format;
};

function initMy(){
    	var chart = new Highcharts.Chart({
			chart : {
				renderTo : 'container',
				defaultSeriesType : 'column'

			},
			title : {
				text : new Date().format("yyyy-MM-dd")+' 进出港航班'
			},

			plotOptions : {
				column : {
					stacking : 'normal'
				},
				series : {
					dataLabels : {
						enabled : true,
						formatter: function() {
					
					if(!isNaN(this.y )){
						
					}else{
					   //alert("不是数字");
					   this.series.options.dataLabels.y=0;
					   this.y=0;
						return "";
					}
						this.series.options.dataLabels.y =
                            this.y >= 0 ? -6 : 12;
						if(this.y<0){
							return 0-this.y ;
							}
						return	this.y;
                    }
					}
				}
			},
			xAxis : {
				categories :arrayAxis,
				title : {
					text : '时间(小时)'
				}
			},

			yAxis : {
				labels : {
					formatter : function() {
				if(!isNaN(this.value )){
					
				}else{
				   //alert("不是数字");
					return 0;
				}
						if (this.value > 0) {
							//alert(this.value);
							return (this.value);
						}else{
							return 0 - this.value;
						}
					}
				},
				title : {
					text : '架次'
				}
			},
			tooltip : {
				formatter : function() {

					
					//alert(this.y);
					if(!isNaN(this.y ) ){
						if (this.y > 0) {return '<b>' + this.y + '</b>';}
						else{return '<b>' + (0 - this.y) + '</b>';}
					}else{
						return '<b>' + 0  + '</b>';
					}
					

				}
			}
			,

			series :
			[{name:'计划出港',
						data :arrayOutPortPlanBar,
						stack : 0,
						color:'#6495ED'						
						}
						,
					{
					name:'计划进港',
						data :arrayInPortPlanBar,
						stack : 0,
						color:'#698B22'
					},
					{
					name:'实际出港',
						data :arrayOutPortActualLine,
						stack : 1,
						type : 'line',
						color:'red'
					},
					{
					name:'实际进港',
						data:arrayInPortActualLine,
						stack : 1,
						type : 'line'
					}
					]

		});
    	chart.redraw();
}



function initArray(){
	if($("#table")!=null){
		//alert("111");
		var d1=	$("#table").getCol("plan_out",false);
		var d2=	$("#table").getCol("plan_in",false);
		var d3=	$("#table").getCol("real_out",false);
		var d4=	$("#table").getCol("real_in",false);
		
     	 d1.shift();
		 d2.shift();
		 d3.shift();
		 d4.shift();
		var chartd1=[];
		var chartd2=[];
		var chartd3=[];
		var chartd4=[];
		for(var i=0;i<24;i++){
                chartd1.push(parseInt(isNaN(d1[i])?0:d1[i]));
				chartd2.push(parseInt(isNaN(d2[i])?0:d2[i]));
				chartd3.push(parseInt(isNaN(d3[i])?0:d3[i]));
				chartd4.push(parseInt(isNaN(d4[i])?0:d4[i]));
			}
		
		arrayOutPortPlanBar  = chartd1
		  arrayInPortPlanBar =chartd2;
		  arrayOutPortActualLine  =chartd3;
		  arrayInPortActualLine =chartd4;
		  
  
	}else{
		
	}
	
	
}


function printArray(){
	alert("出港计划:"+arrayInPortPlanBar+"\n"+"进港计划:"+arrayOutPortPlanBar+"\n"+"实际出港:"+arrayInPortActualLine+"\n"+"实际进港计划:"+arrayOutPortActualLine+"\n");
}

